package me.fanwu;

import com.jfinal.kit.PathKit;
import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
import com.jfinal.plugin.activerecord.generator.Generator;
import com.jfinal.plugin.druid.DruidPlugin;

import javax.sql.DataSource;

/*
 * Wupher 编写于 2016/10/27.
 */
public class ModelGenerator {
    private static DataSource getDataSource() {
        DruidPlugin druidPlugin = new DruidPlugin("jdbc:mysql://localhost:3306/final", "fanwu", "123456");
        druidPlugin.start();
        return druidPlugin.getDataSource();
    }

    public static void main(String[] args) {
        String baseModelPkg = "me.fanwu.model.base";
        String baseModelDir = PathKit.getWebRootPath() + "/src/main/java/me/fanwu/model/base";


        String modelPkg = "me.fanwu.model";
        String modelDir = baseModelDir + "/..";

        Generator generator = new Generator(getDataSource(), baseModelPkg, baseModelDir,modelPkg, modelDir);
        generator.setDialect(new MysqlDialect());
        generator.setGenerateDaoInModel(true);
        generator.generate();
    }
}
